#ifndef _MAPSCENE_H_
#define _MAPSCENE_H_


#include "MapGrid.h"
#include "GameNpc.h"




class MapScene
{
public:

	MapScene();
	~MapScene();


	fvoid			Init( fint32 maxX , fint32 maxY );
	
	fint32			GetID();
	fvoid			SetID( fint32 id );


	fvoid			Update( freal32 delta );

    fbool           CheckGrid( fint32 x , fint32 y );
    
	MapGrid*		GetGrid( const MapGridID& grid );
	fint32			GetIndex( const MapGridID& id );

	fvoid			SetBlock( const MapGridID& id , fbool b = F_TRUE );
	fbool			IsBlock( const MapGridID& id );

    fvoid			SendMsgToAllMove( netMsgHead* msg , fint32 self = INVALID_ID );
	fvoid			SendMsgToAll( netMsgHead* msg , fint32 self = INVALID_ID );
	fvoid			AddPlayer( GamePlayer* p );
	fvoid			RemovePlayer( GamePlayer* p );

	fvoid			SynPlayers( GamePlayer* p );
	fvoid			SynPlayersEnter( GamePlayer* p );
	fvoid			SynPlayersExit( GamePlayer* p );

	fvoid			Direction( GamePlayer* player , fint32 direction );

	fvoid			AddNpc( GameNpc* n );
	fvoid			RemoveNpc( GameNpc* n );
	GameNpc*		GetNpc( fint32 id );
	fvoid			MoveNpc( GameNpc* n );

	//////////////////////////////////////////////////////////////////////////
	// move

	fbool			AddMove( GameCreature* c , fint32* path , fint32 count );
	
    fint32          GetIndex( fint32 x , fint32 y );
    fint32          GetXWithIndex( fint32 index );
    fint32          GetYWithIndex( fint32 index );
    
	fbool           UncompressePath( fint32* path , fint32 count );

    GamePlayerList* GetPlayerLists();
    
protected:
private:

    static MapGridIDVector sPathCache;
    
	GameCreatureMap	mNpc;
	GameCreatureList	mMoveCreatures;

	//MapMove			mMove;

	fint32			mID;

	fint32			mMaxGridX;
	fint32			mMaxGridY;

	MapGrid*		mMapGrids;
	GamePlayerList	mPlayers;
};


typedef map< fint32 , MapScene* > MapSceneMap;
typedef map< fint32 , MapScene* >::iterator MapSceneMapIter;


typedef vector< MapScene* > MapSceneVector;
typedef vector< MapScene* >::iterator MapSceneVectorIter;


#endif

